﻿using HSGD.Common.HttpContextUser;
using HSGD.IServices.HSGD_Logs;
using HSGD.Repository.UnitOfWorks;
using HSGDcIS.IServices.HSGD_Family;
using Microsoft.AspNetCore.Mvc;
using HSGD.Model.Dtos.HSGD_Family;
using HSGD.Model.Models.HSGD_Family;
using HSGD.Model.Common;

namespace HSGD.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize(Permissions.Name)]
    public class ChildController : ControllerBase {
        private readonly IChildServices childServices;
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IUser _user;
        public readonly IHSGDLogsServices _logsServices;
        //public IRefEmailNoticeServices _refEmailNoticeServices { get; set; }

        public ChildController(IChildServices _childServices, IUnitOfWorkManage unitOfWorkManage, IUser user,
            IHSGDLogsServices logsServices
            ) {
            childServices = _childServices;
            _unitOfWorkManage = unitOfWorkManage;
            _user = user;
            _logsServices = logsServices;
        }


        [HttpGet]
        [Route("api/child")]
        //[Authorize(Roles = ADMIN)]
        //[Authorize("Permission")]
        public async Task<object> Get() {
            try {
                var query = await childServices.GetChildByIdAsync(90972);
                return MessageModel<ChildDto>.Success(query!);
                //var child = query.FirstOrDefault(x => x.child_id == 90972);
                //return MessageModel<ChildDto>.Success(child!);
            }
            catch (Exception ex) {
                await Console.Out.WriteLineAsync(ex.Message);
                //Console.WriteLine($"3 third time : the count of role is :{roles3.Count}");
                return MessageModel<ChildDto>.Fail($"{ex.Message}->{ex.StackTrace}");
            }
        }

    }
}